package com.m3958.firstgwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.m3958.firstgwt.client.resource.FirstGwtResource;
import com.m3958.firstgwt.client.utils.HelpUrlMap;
import com.m3958.gwtutil.clientside.client.AjaxResult;
import com.m3958.gwtutil.clientside.client.SmartFetchPara;
import com.m3958.gwtutil.clientside.client.interfac.IwantAjaxResult;
import com.m3958.gwtutil.clientside.client.utils.HttpAjax;

public class QuickStartPage extends Composite implements IwantAjaxResult{

	private static QuickStartPageUiBinder uiBinder = GWT
			.create(QuickStartPageUiBinder.class);

	interface QuickStartPageUiBinder extends UiBinder<Widget, QuickStartPage> {
	}
	
	@UiField
	DivElement updatingNews;
	
	@UiField
	DivElement contactUs;
	
	@Inject
	public QuickStartPage(HelpUrlMap hum,HttpAjax ajax) {
		initWidget(uiBinder.createAndBindUi(this));
		String frontLeftUrl = hum.getUrl("frontLeft");
		SmartFetchPara sfp = new SmartFetchPara();
		sfp.put("locale", LocaleInfo.getCurrentLocale().getLocaleName());
		sfp.putUrl(frontLeftUrl);
		ajax.fetch(sfp.getMap(), this, "frontLeft");
	}

	@Override
	public void onAjaxDataArrival(AjaxResult ar) {
		String s = ar.getStringValue();
		if("frontLeft".equals(ar.getDistinct())){
			updatingNews.setInnerHTML(s);
		}
	}

}
